package models

import (
	// "fmt"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
	"time"
)

type Resume struct {
	Id                    int       `orm:"column(Id);auto"`
	Logo                  string    `orm:"column(Logo);null"`
	TrueName              string    `orm:"column(TrueName);null"`
	Gender                int       `orm:"column(Gender);type(int);size(11);null"`
	Age                   int       `orm:"column(Age);type(int);size(11);null"`
	Experience            int       `orm:"column(Experience);type(int);size(250);null"`
	Mobile                string    `orm:"column(Mobile);size(250);null"`
	Qq                    int       `orm:"column(Qq);type(int);size(250);null"`
	Email                 string    `orm:"column(Email);size(50);null"`
	TargetProvince        string    `orm:"column(TargetProvince);size(255);null"`
	TargetCity            string    `orm:"column(TargetCity);size(255);null"`
	TargetPosition        string    `orm:"column(TargetPosition);size(255);null"`
	ExpectedMonthlySalary string    `orm:"column(ExpectedMonthlySalary);size(255);null"`
	WkIDSArray            string    `orm:"column(WkIDSArray);size(255);null"`
	WkExperice            string    `orm:"column(WkExperice);size(4000);null"`
	EduIDSArray           string    `orm:"column(EduIDSArray);size(255);null"`
	EduExperice           string    `orm:"column(EduExperice);size(4000);null"`
	ProjectExperice       string    `orm:"column(ProjectExperice);size(255);null"`
	Remarks               string    `orm:"column(Remarks);size(4000);null"`
	CreateByUid           int       `orm:"column(CreateByUid);null"`
	CreateDate            time.Time `orm:"column(CreateDate);auto_now_add;type(datetime);null"`
	UpdateDate            time.Time `orm:"column(UpdateDate);auto_now;type(datetime);null"`
	Status                int       `orm:"column(Status);null"`
}

func init() {
	orm.RegisterModel(new(Resume))
}

func (t *Resume) TableName() string {
	return "057dg_resume"
}

func AddResume(m *Resume) (id int64, err error) {
	orm := orm.NewOrm()
	id, err = orm.Insert(m)
	return
}

func (this *Resume) UpdateResume(R *Resume) (num int64, err error) {
	o := orm.NewOrm()
	num, err = o.Update(R)
	if err == nil {
		return num, nil
	}
	return num, err
}

func (this *Resume) FindOneResume(id int) (resume *Resume, err error) {
	o := orm.NewOrm()
	resume = &Resume{CreateByUid: id}
	if err := o.Read(resume, "CreateByUid"); err == nil {
		return resume, nil
	}
	return nil, err

}
